/*
ID: simplyz2
LANG: C
TASK: beads
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LEN 351
int len;
char str[MAX_LEN*2];

int
solve(char *rbw)
{
	int i, begin, total = 0;
	char ch;
	for(begin=0; begin<len&&rbw[begin]=='w'; begin++)
		++total;
	for(i=begin; (i<len)&&((rbw[i]==rbw[begin])||(rbw[i]=='w')); i++)
		++total;
	for(begin=len-1; begin>=0&&rbw[begin]=='w'; begin--)
		++total;
	for(i=begin; (i>=0)&&((rbw[i]==rbw[begin])||(rbw[i]=='w')); i--) 
		++total;
	return total;
}

int
main(int argc, char **argv)
{
	int i, t, rt;
	char tmp[MAX_LEN];
	freopen("beads.in", "r", stdin);
	freopen("beads.out", "w", stdout);
	while(scanf("%d%s", &len, tmp) != EOF) {
		rt = 0;
		strcpy(str, tmp);
		strcat(str, tmp);
		/* 
		 * enumerate each break point, O(n*n)
		 */
		for(i=0; i<len; i++) {
			t = solve(str+i);
			rt = t > rt ? t : rt;
		}
		printf("%d\n", rt>len ? len : rt);
	}
	exit(0);
}
